from fastapi import FastAPI
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from mcp.math import calculator
from mcp.wearther import get_weather


# model = ChatOpenAI(
#         model = "deepseek-chat",
#         api_key = "sk-c2acb26542994445a95052fbcae9cd02",
#         base_url = "https://api.deepseek.com/v1",
#         temperature=0
#     )


model = ChatOpenAI(
        model = "qwen3:8b",
        api_key = "sk-c",
        base_url = "http://127.0.0.1:11434/v1",
        temperature=0
    )


async def build_agent(app: FastAPI):
    saver=app.state.saver
    agent = create_react_agent(
        model=model,
        tools=[calculator, get_weather],
        checkpointer= saver
    )
    return agent